﻿namespace DeltaGroup.WheelOfJeopardy.UI.Commands
{
    using System.Windows;
    using System.Windows.Input;

    using DeltaGroup.WheelOfJeopardy.GameManager;
    using DeltaGroup.WheelOfJeopardy.UI.Screens;
    using DeltaGroup.WheelOfJeopardy.UI.ViewModel;

    public class StartGameCommand : LoadUserControlCommand<GamePanel>
    {
        #region Methods

        public override void Load(Window window, ExecutedRoutedEventArgs executedRoutedEventArgs)
        {
            base.Load(window, executedRoutedEventArgs);

            var parameter = executedRoutedEventArgs.Parameter as SetupModel;

            var game = Game.New(parameter, ChallengeManager.ChallengeManager.GetInstance());

            game.Jeopardy.UIManager = UserControlInstance;
            game.Jeopardy.Finished += (sender, args) => WoJCommands.EndJeopardy.Execute(null, window);
            UserControlInstance.DataContext = new NormalRoundViewModel("Jeopardy", game.Jeopardy, game.Contestants, Game.Settings.DebugMode);
            game.Jeopardy.Start();
        }

        #endregion Methods
    }
}